﻿//INSTANT C# NOTE: Formerly VB.NET project-level imports:
using System.Linq;
using System.Xml.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;

namespace DataBinding
{
	public class PersonProfessionDataTemplateSelector : DataTemplateSelector
	{

		public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
		{

			if (item != null && item is Person)
			{
				Person objPerson = (Person)item;

				if (objPerson.Profession.Contains("Agent"))
				{
					return MyWpfExtension.Application.Current.MainWindow.TryFindResource("agentDataTemplate") as DataTemplate;
				}
				else
				{
					return MyWpfExtension.Application.Current.MainWindow.TryFindResource("nonAgentDataTemplate") as DataTemplate;
				}

			}
			else
			{
				return null;
			}
		}

	}

} //end of root namespace